/* Copyright (c) 2004-2024 peigen.info. All rights reserved. */

package info.peigen.hotpot.business.customer.manage.convertor;

import cn.hutool.core.bean.BeanUtil;
import info.peigen.hotpot.business.customer.core.domain.CustomerLog;
import info.peigen.hotpot.business.customer.core.repository.entity.CustomerLogEntity;
import info.peigen.hotpot.business.customer.manage.form.CustomerLogManageCreateForm;
import info.peigen.hotpot.business.customer.manage.form.CustomerLogManageEditForm;
import info.peigen.hotpot.business.customer.manage.form.CustomerLogManageSearchForm;
import info.peigen.hotpot.business.customer.manage.info.CustomerLogManageInfo;
import info.peigen.hotpot.common.core.util.IdUtil;
import lombok.extern.slf4j.Slf4j;

/**
 * <b>(CustomerLogManageConvertor)</b>
 * 管理后台领域对象 "客户登录日志" 转换器
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2023-09-08
 */
@SuppressWarnings("unused")
@Slf4j
public class CustomerLogManageConvertor {
    // ConvertToEntity
    public static CustomerLogEntity convertToEntity(CustomerLog domain) {
        return BeanUtil.copyProperties(domain, CustomerLogEntity.class);
    }

    public static CustomerLogEntity convertToEntity(CustomerLogManageInfo info) {
        return BeanUtil.copyProperties(info, CustomerLogEntity.class);
    }

    public static CustomerLogEntity convertToEntity(CustomerLogManageSearchForm form) {
        return BeanUtil.copyProperties(form, CustomerLogEntity.class);
    }

    public static CustomerLogEntity convertToEntity(CustomerLogManageCreateForm form) {
        if (form.getCustomerId() == null) {
            form.setCustomerId(IdUtil.id());
        }
        return BeanUtil.copyProperties(form, CustomerLogEntity.class);
    }

    public static CustomerLogEntity convertToEntity(CustomerLogManageEditForm form) {
        return BeanUtil.copyProperties(form, CustomerLogEntity.class);
    }

    // ConvertToDomain
    public static CustomerLog convertToDomain(CustomerLogEntity entity) {
        return BeanUtil.copyProperties(entity, CustomerLog.class);
    }

    public static CustomerLog convertToDomain(CustomerLogManageInfo info) {
        return BeanUtil.copyProperties(info, CustomerLog.class);
    }

    public static CustomerLog convertToDomain(CustomerLogManageSearchForm form) {
        return BeanUtil.copyProperties(form, CustomerLog.class);
    }

    public static CustomerLog convertToDomain(CustomerLogManageCreateForm form) {
        if (form.getCustomerId() == null) {
            form.setCustomerId(IdUtil.id());
        }
        return BeanUtil.copyProperties(form, CustomerLog.class);
    }

    public static CustomerLog convertToDomain(CustomerLogManageEditForm form) {
        return BeanUtil.copyProperties(form, CustomerLog.class);
    }

    // convertToInfo
    public static CustomerLogManageInfo convertToInfo(CustomerLog domain) {
        return BeanUtil.copyProperties(domain, CustomerLogManageInfo.class);
    }

    public static CustomerLogManageInfo convertToInfo(CustomerLogEntity entity) {
        return BeanUtil.copyProperties(entity, CustomerLogManageInfo.class);
    }

    public static CustomerLogManageInfo convertToInfo(CustomerLogManageSearchForm form) {
        return BeanUtil.copyProperties(form, CustomerLogManageInfo.class);
    }

    public static CustomerLogManageInfo convertToInfo(CustomerLogManageCreateForm form) {
        if (form.getCustomerId() == null) {
            form.setCustomerId(IdUtil.id());
        }
        return BeanUtil.copyProperties(form, CustomerLogManageInfo.class);
    }

    public static CustomerLogManageInfo convertToInfo(CustomerLogManageEditForm form) {
        return BeanUtil.copyProperties(form, CustomerLogManageInfo.class);
    }
}